package com.googlecode.spruce.dao.impl;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.googlecode.spruce.dao.AbstractDao;
import com.googlecode.spruce.dao.HostDao;
import com.googlecode.spruce.domain.Host;

@Repository
@Transactional
public class DefaultHostDao extends AbstractDao<Integer, Host> implements HostDao
{

    public DefaultHostDao()
    {
        super(Host.class);
    }

    @Override
    public Host findByName(final String name)
    {
        final Query query = super.getSession().createQuery("from Host where name = :name");
        query.setParameter("name", name);
        return (Host) query.list().get(0);
    }

}
